import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import Inspect from 'vite-plugin-inspect'
// @ts-ignore
import AutoRouter from 'vite-plugin-auto-react-router'
// @ts-ignore
import path from 'path'

const pathResolve = (dir: string) => {
  return path.resolve('.', dir)
}

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react(),
    Inspect(),
    AutoRouter({
      name: "routes",
      pageDir: "./src/views",
      pageFileType: ['jsx', 'tsx'],
      output: "./src",
      lazy: true,
      enableVirtualRouter: true,
    }),
  ],
  resolve: {
    extensions: [
      '.mjs',
      '.js',
      '.ts',
      '.jsx',
      '.tsx',
      '.json',
      '.scss',
      '.css',
    ],
    alias: {
      '@': pathResolve("src"),
    },
  },
})
